package com.example.lanouhn.bantangapp.activities.adapters;

import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import com.example.lanouhn.bantangapp.R;
import com.example.lanouhn.bantangapp.activities.contants.Thehotestweek;
import com.example.lanouhn.bantangapp.activities.contants.Useroriginal;
import com.nostra13.universalimageloader.core.ImageLoader;
import com.nostra13.universalimageloader.core.ImageLoaderConfiguration;
import com.squareup.picasso.Picasso;

import java.util.List;

/**
 * Created by lanouhn on 16/7/20.
 * 一周最热数据
 */
public class Adapter_FThehotestweek extends RecyclerView.Adapter<Adapter_FThehotestweek.MyViewHolder> {
    private Context context;
    List<Thehotestweek> list;

    public Adapter_FThehotestweek(Context context, List<Thehotestweek> list) {
        this.context = context;
        this.list = list;

    }

    @Override
    public MyViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {

        View view = LayoutInflater.from(context).inflate(R.layout.fragment_thehottestweek_item,null);
        MyViewHolder viewHolder = new MyViewHolder(view);
        return viewHolder;
    }

    @Override
    public void onBindViewHolder(MyViewHolder holder, int position) {
         //设置值
        holder.thehottestweek_item_title.setText(list.get(position).getTitle());
        holder.thehottestweek_item_center.setText(list.get(position).getLikes());
        holder.thehottestweek_item_textright.setText(list.get(position).getComments());
        holder.thehottestweek_item_textleft.setText(list.get(position).getNickname());

        //图片
        Picasso.with(context).load(list.get(position).getPic()).into(holder.thehottestweek_item_pic);

    }

    @Override
    public int getItemCount() {
        return list.size();
    }

    class MyViewHolder extends RecyclerView.ViewHolder{
        //找到控件
        private ImageView thehottestweek_item_pic;
        private TextView  thehottestweek_item_title;
        private TextView thehottestweek_item_center;
        private TextView   thehottestweek_item_textright;
        private TextView   thehottestweek_item_textleft;
        public MyViewHolder(View itemView) {
            super(itemView);
            thehottestweek_item_pic = (ImageView) itemView.findViewById(R.id.thehottestweek_item_pic);
            thehottestweek_item_title= (TextView) itemView.findViewById(R.id.thehottestweek_item_title);
            thehottestweek_item_center= (TextView) itemView.findViewById(R.id.thehottestweek_item_center);
            thehottestweek_item_textright= (TextView) itemView.findViewById(R.id.thehottestweek_item_textright);
            thehottestweek_item_textleft = (TextView) itemView.findViewById(R.id.thehottestweek_item_textleft);

        }
    }
}
